package com.smartHome.service.impl;

import com.smartHome.mapper.SceneDeviceMapper;
import com.smartHome.pojo.dto.SceneDeviceStatusDTO;
import com.smartHome.pojo.entity.SceneDevice;
import com.smartHome.service.SceneDeviceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class SceneDeviceServiceImpl implements SceneDeviceService {
    @Autowired
    private SceneDeviceMapper sceneDeviceMapper;

    @Override
    public List<SceneDevice> getSceneDeviceList(Integer sceneId) {
        List<SceneDevice> sceneDeviceList = sceneDeviceMapper.getSceneDeviceList(sceneId);
        return sceneDeviceList;
    }



    @Override
    @Transactional
    public void batchUpdateStatus(List<SceneDevice> statusList) {
        for (SceneDevice dto : statusList) {
            sceneDeviceMapper.updateStatus(dto.getSceneDeviceId(), dto.getStatus());
        }
    }
}
